﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;


public class EditorDragableItem
{
    Texture2D TaskBorder;
    public Vector2 position {
        get
        {
            return rectInScroll.position;
        }
    }
    /// <summary>整个Scroll中的位置 </summary>
    protected Rect rectInScroll = new Rect(0, 0, 150, 90);
    /// <summary>可视范围中的位置 </summary>
    public Rect rectInGraph = new Rect(0, 0, 150, 90);

    public bool IsClicking;
    private Vector2 offset;
    public void InitTexture(Texture2D item)
    {
        TaskBorder = item;
    }

    public void SetPosition(Vector2 position)
    {
        rectInScroll.position = position;
    }

    public virtual void DrawItem(Vector2 offset)
    {
        if (TaskBorder == null)
        {
            TaskBorder = EditorWindowUtils.LoadTexture("TaskBorder.png");
        }

        this.offset = offset;
        rectInGraph.position = rectInScroll.position - offset;
        GUI.DrawTexture(rectInGraph, TaskBorder, ScaleMode.StretchToFill);
    }

    public void CheckClick(Vector2 point)
    {
        if (rectInGraph.Contains(point))
        {
            IsClicking = true;
        }
        else
        {
            IsClicking = false;
        }
    }
}
